package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.Attribute;

/**
 * QAttribute is a ORMLite query type for Attribute
 * @see Attribute
 */
public class QAttribute extends QEntityBase<Attribute> {

    public static final QAttribute $ = new QAttribute("ATTRIBUTE");

    public final Column name = field("name").columnName("NAME").varchar(32).notNull().build();

    public final Column seqOrder = field("seqOrder").columnName("SEQ_ORDER").integer().notNull().build();

    public final Column attributeGroupId = field("attributeGroupId").columnName("ATTRIBUTE_GROUP_ID").varchar(22).notNull().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndexA = index("CONSTRAINT_INDEX_A").column(attributeGroupId).build();

        public final Index primaryKeyA = index("PRIMARY_KEY_A").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintA6 = foreignKey(attributeGroupId, "ATTRIBUTE_GROUP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QAttribute(String tableName) {
        super(Attribute.class, tableName);
    }

    @Override
    public Attribute newInstance() {
        return new Attribute();
    }

    @Override
    public Object getFieldValue(Attribute instance, String fieldName) {
        switch (fieldName) {
            case "name":
                return instance.getName();
            case "seqOrder":
                return instance.getSeqOrder();
            case "attributeGroupId":
                return instance.getAttributeGroupId();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(Attribute instance, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                instance.setName((java.lang.String) value);
                break;
            case "seqOrder":
                instance.setSeqOrder((java.lang.Integer) value);
                break;
            case "attributeGroupId":
                instance.setAttributeGroupId((java.lang.String) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

